Skip to content

Comments

Refactored data provider service registrations#31

Merged
prochnowc merged 5 commits intomainfrom
feat/keyed-registrations
Jun 26, 2025
Merged

Refactored data provider service registrations#31
prochnowc merged 5 commits intomainfrom
feat/keyed-registrations

Conversation

@prochnowc
Copy link
Contributor

Closes #27

@prochnowc prochnowc requested a review from Copilot June 26, 2025 15:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how data providers are registered and resolved, replacing the custom ProviderRegistration approach with keyed DI registrations and factories. Major updates include renaming configuration properties, introducing MongoClientProvider, and simplifying constructors in MongoDB/EF providers.

  • Replace ProviderRegistration with keyed service descriptors in DataProviderBuilderExtensions
  • Update DataProviderResolver to directly resolve via IEnumerable<IDataProvider>
  • Rename DatabaseDatabaseName in options and wire up MongoClientProvider

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/AppCoreNet.Data/DependencyInjection/DataProviderBuilderExtensions.cs Replaced custom registrations with keyed DI patterns
src/AppCoreNet.Data/DataProviderResolver.cs Simplified resolution logic, updated error message
src/AppCoreNet.Data.MongoDB/MongoRepository.cs Added overridable GetPrimaryKey for complex IDs
src/AppCoreNet.Data.MongoDB/DependencyInjection/MongoDataProviderBuilderExtensions.cs Introduced MongoClientProvider and updated builder
test/AppCoreNet.Data.MongoDB.Tests/MongoTestEntity2Repository.cs Added unused usings and left commented-out override stub
Comments suppressed due to low confidence (2)

src/AppCoreNet.Data/DataProviderResolver.cs:27

  • [nitpick] The exception message could be clearer if it follows the pattern in other providers, e.g. Data provider with name '{name}' is not registered. for consistency.
            throw new InvalidOperationException($"There is no data provider registered with '{name}'.");

src/AppCoreNet.Data.MongoDB/MongoRepository.cs:157

  • You've introduced a customizable GetPrimaryKey method; consider adding unit tests covering primitive, Guid, and complex ID scenarios to ensure correct BSON conversion.
    protected virtual BsonValue GetPrimaryKey(TId id)

@prochnowc prochnowc merged commit 7798c8a into main Jun 26, 2025
6 checks passed
@prochnowc prochnowc deleted the feat/keyed-registrations branch June 26, 2025 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use keyed services instead of IDataProviderResolver

1 participant